import http from '@/util/http'

const module = {
  namespaced: true,
  state: {
    cinemalist: []
  },
  mutations: {
    setCinemaList (state, cinemas) {
      state.cinemalist = cinemas
    },
    clearCinemaList (state) {
      state.cinemalist = []
    }
  },
  actions: {
    cinemaGetMessage (store, cityId) {
      return http({
        url: `/gateway?cityId=${cityId}&ticketFlag=1&k=1617984`,
        headers: { 'X-Host': 'mall.film-ticket.cinema.list' }
      }).then(res => {
        // console.log(res.data.data.address)
        // this.datalist = res.data.data.cinemas
        // 状态更新后，等待dom渲染完毕

        // 仍走commit监控状态
        // console.log(res.data)
        store.commit('setCinemaList', res.data.data.cinemas)
        // console.log(res.data.data.cinemas)
      })
    }
  }
}
export default module
